home *** CD-ROM | disk | FTP | other *** search
- ;Colour List Example
- ;-------------------
- ;Colourlists are those nice colour gradients used in demos and games,
- ;usually sitting in the background of your screen. Colourlists are mostly
- ;good for getting more colours on screen than what there really is.
- ;Although the games.library allows you to do other screen effects based on
- ;raster lines, we'll just stick to changing colours in this demo.
- ;
- ;You can move the green colour bar by moving the joystick up and down.
- ;You will notice that if you move the green bar into the upper red bar,
- ;your bar will disappear. This is because:
- ;
- ; WAITLINE 95 ;Wait for line 95
- ; WAITLINE 100 ;Wait for line 100
- ; WAITLINE 90 ;Wait for line 90 <--Error!
- ;
- ;Is not allowed. The monitor beam travels down the screen, and so the
- ;Update_RasterList routine will expect all lines to be in sequential order.
- ;Moving two colourbars into each other breaks this rule, causing the wait
- ;command to be ignored. If you want to get around this, you will have to
- ;have just one large colourlist and sort your colours before each call to
- ;Update_RasterList.
- ;
- ;Similarly if you move the colour bar too far down the screen the hardware
- ;won't like it because lines > 311 don't exist. It's up to you to be
- ;responsible enough to stop this from happening!
- ;
- ;Press FIRE to exit the demo.
-
- opt o+
-
- INCLUDE "exec/exec_lib.i"
- INCLUDE "games/games_lib.i"
- INCLUDE "games/games.i
-
- LOCAL = 0
-
- CALL MACRO
- jsr _LVO\1(a6)
- ENDM
-
- ;===========================================================================;
- ; INITIALISE DEMO
- ;===========================================================================;
-
- SECTION "ColourList",CODE
-
- Start: MOVEM.L A0-A6/D1-D7,-(SP)
- move.l ($4).w,a6
- lea GMS_Name(pc),a1
- moveq #$00,d0
- CALL OpenLibrary
- move.l d0,GMS_Base
- beq.s Quit
-
- move.l GMS_Base(pc),a6
- CALL SetUserPri
-
- move.l GMS_Base(pc),a6 ;Tell GMS that we want to add a
- lea ScreenStruct(pc),a0 ;screen for use.
- CALL Add_Screen
- tst.l d0
- bne.s Error
-
- lea ScreenStruct(pc),a0 ;Now show the screen/pic.
- CALL Show_Screen
-
- ;===========================================================================;
- ; MAIN LOOP
- ;===========================================================================;
-
- Loop: moveq #JPORT2,d0 ;Port 2
- moveq #JT_SWITCH,d1
- CALL Read_JoyPort
- btst #JS_FIRE1,d0
- bne.s .Finished
-
- .TUp btst #JS_UP,d0
- beq.s .TDown
- moveq #-1,d0
- bsr.s Move_List
- bra.s .done
- .TDown btst #JS_DOWN,d0
- beq.s .done
- moveq #1,d0
- bsr.s Move_List
-
- .done CALL Wait_OSVBL
- bra.s Loop
-
- ;===========================================================================;
- ; RETURN TO DOS
- ;===========================================================================;
-
- .Finished
- CALL Delete_Screen ;Give back screen memory etc.
- Error move.l GMS_Base(pc),a1
- move.l ($4).w,a6
- CALL CloseLibrary
- Quit MOVEM.L (SP)+,A0-A6/D1-D7
- moveq #$00,d0
- rts
-
- ;===========================================================================;
- ; EXTRA ROUTINES
- ;===========================================================================;
-
- Move_List:
- lea Bar2(pc),a1
- add.w d0,2(a1)
- lea ScreenStruct(pc),a0 ;Update our rasterlist.
- CALL Update_RasterList
- rts
-
- ;===========================================================================;
- ; DATA
- ;===========================================================================;
-
- GMS_Name:
- dc.b "games.library",0
- even
- GMS_Base:
- dc.l 0
-
- AMT_PLANES = 5
-
- ScreenStruct:
- dc.l "GSV1" ;Structure version.
- dc.l 0,0,0 ;Screen_Mem1/2/3
- dc.l 0 ;Screen link.
- dc.l 0 ;Address of screen palette.
- dc.l RasterList ;Address of rasterlist.
- dc.l 0 ;Amt of colours in palette.
- dc.w 256,320,320/8 ;Screen Height, width, width/8
- dc.w 256,320,320/8 ;Pic Height, width, width/8
- dc.w AMT_PLANES ;Amt_Planes
- dc.w 0,0 ;Top Of Screen: X,Y
- dc.w 0 ;Scroll buffer size.
- dc.w 0,0 ;X/Y scroll counters.
- dc.l NOBURST|BLKBDR ;Special attributes.
- dc.w LORES ;Screen mode.
- dc.b INTERLEAVED ;Screen type
- dc.b 0 ;Displayed?
- dc.l 0,0 ;Reserved area.
- even
-
- ScreenPalette:
- dc.w $0000
-
- ;===========================================================================;
-
- RasterList:
- COL12LIST 000,3,00,ColourBar1 ;Line, Skip, Colnum, ColourList.
- Bar2: COL12LIST 160,1,00,ColourBar2 ;Line, Skip, Colnum, ColourList.
- COL12LIST 230,1,00,ColourBar3 ;Line, Skip, Colnum, ColourList.
- RASTEND
-
- ColourBar1:
- dc.w $100,$200,$300,$400,$500,$600,$700,$800,$900,$a00
- dc.w $b00,$c00,$d00,$e00,$f00,$e00,$d00,$c00,$b00,$a00
- dc.w $900,$800,$700,$600,$500,$400,$300,$200,$100,$000
- dc.l -1
-
- ColourBar2:
- dc.w $010,$020,$030,$040,$050,$060,$070,$080,$090,$0a0
- dc.w $0b0,$0c0,$0d0,$0e0,$0f0,$0e0,$0d0,$0c0,$0b0,$0a0
- dc.w $090,$080,$070,$060,$050,$040,$030,$020,$010,$000
- dc.l -1
-
- ColourBar3:
- dc.w $001,$002,$003,$004,$005,$006,$007,$008,$009,$00a
- dc.w $00b,$00c,$00d,$00e,$00f,$00e,$00d,$00c,$00b,$00a
- dc.w $009,$008,$007,$006,$005,$004,$003,$002,$001,$000
- dc.l -1
-